﻿using IterationLife.ContentResources.Models;
using Util;
using Util.Maps;

namespace IterationLife.PlatformBackEnd.AppServices.Dtos.ContentResources {
    /// <summary>
    /// 内容资源图集数据传输对象扩展
    /// </summary>
    public static class ContentResourcePictureDtoExtension {
        /// <summary>
        /// 转换为内容资源图集实体
        /// </summary>
        /// <param name="dto">内容资源图集数据传输对象</param>
        public static ContentResourcePicture ToEntity( this ContentResourcePictureDto dto ) {
            if ( dto == null )
                return new ContentResourcePicture();
            return dto.MapTo( new ContentResourcePicture( dto.Id.ToGuid() ) );
        }
        
        /// <summary>
        /// 转换为内容资源图集数据传输对象
        /// </summary>
        /// <param name="entity">内容资源图集实体</param>
        public static ContentResourcePictureDto ToDto(this ContentResourcePicture entity) {
            if( entity == null )
                return new ContentResourcePictureDto();
            return entity.MapTo(new ContentResourcePictureDto());
        }
    }
}
